package com.ymatou.shoppingcart.api.testcase;

import java.util.Map;
import java.util.Random;

import org.junit.After;
import org.junit.AfterClass;
import org.junit.Before;
import org.junit.BeforeClass;
import org.junit.Test;
import org.junit.experimental.categories.Category;

import com.ymatou.shoppingcart.api.parameter.AddCatalogToCartBean;
import com.ymatou.shoppingcart.api.service.AddCatalogToCartCall;
import com.ymt.core.tool.Logger;
import com.ymt.utils.annotation.TestCase;
import com.ymt.utils.annotation.TestSuite;
import com.ymt.utils.tag.P1;
import com.ymt.utils.tag.P2;
import com.ymt.utils.tag.P3;
import com.ymttest.business.database.ActivityInfo;
import com.ymttest.business.database.ProductInfo;
import com.ymttest.business.service.ShoppingCartCallServices;
import com.ymttest.database.mongo.ShopCartMongoBean;
import com.ymttest.database.mongo.ShoppingCartMongoWapper;
import com.ymttest.utils.TestDataManager;
import com.ymttest.utils.constant.ECode;

/**
 * 新增商品到购物车 FreeMaker Template自动生成代码
 */
@TestSuite
public class Ts_AddCatalogToCart {
	private static AddCatalogToCartBean addcatalogtocartbean;
	private static AddCatalogToCartCall addcatalogtocartcall;
	private static ShoppingCartMongoWapper scmw;

	@BeforeClass
	public static void setUp() {
		Logger.createResultFile("新增商品到购物车");
	}

	@Before
	public void caseUp() {
		addcatalogtocartbean = new AddCatalogToCartBean();
		addcatalogtocartcall = new AddCatalogToCartCall();
		try {
			scmw = new ShoppingCartMongoWapper();
		} catch (Exception e) {
			Logger.setup("MongoDB初始化失败：" + e.getMessage(), -1);
		}
	}

	@AfterClass
	public static void tearDown() {
		Logger.generateResult(addcatalogtocartcall.getOpurl());
	}

	@After
	public void caseDown() {
		Logger.end();
	}

	//TODO 购物车表和结构都有修改，case需要对应调整
	/*@Test
	@Category(P1.class)
	@TestCase
	public void Tc_AddCatalogToCart_001() {
		Logger.start(true,"新增商品到购物车成功");
		try {
			// 随机获取appid 0~6 Unknown=0,洋码头PC端(1)
			// Ymt_PC=1,洋码头WAP(2)Ymt_WAP=2,洋码头APP(3)Ymt_APP=3,神器APP(4)Shangou_APP=4,神器WAP(5)Shangou_WAP=5,神器PC端(6)Shangou_PC=6
			Logger.comment("随机获取appid 0~6");
			String appid = String.valueOf(new Random().nextInt(7));
			Logger.comment("随机获取一个uuid");
			String uid = TestDataManager.getRandomUUID().toString();
			Map productinfo = ActivityInfo.getActiveProductInfoList().get(0);
			Logger.comment("从数据库中捞取一条记录，获取catalogId");
			String catalogId = (String) productinfo.get("CatalogId");
			Logger.comment("从数据库中捞取一条记录，获取SellerId");
			String sellerId = String.valueOf(productinfo.get("SellerId"));
			Logger.comment("从数据库中捞取一条记录，获取loginId");
			String loginId = String.valueOf(productinfo.get("loginId"));
			int count = 1;
			Logger.comment("setAppSource:" + appid);
			addcatalogtocartbean.setAppSource(appid);
			Logger.comment("setCatalogId:" + catalogId);
			addcatalogtocartbean.setCatalogId(catalogId);
			Logger.comment("setCount:" + count);
			addcatalogtocartbean.setCount(count);
			Logger.comment("setCountryId:" + "2");
			addcatalogtocartbean.setCountryId("2");
			Logger.comment("setSellerId:" + sellerId);
			addcatalogtocartbean.setSellerId(sellerId);
			Logger.comment("setSellerLoginId:" + loginId);
			addcatalogtocartbean.setSellerLoginId(loginId);
			Logger.comment("setUserId:" + uid);
			addcatalogtocartbean.setUserId(uid);
			addcatalogtocartcall.setData(addcatalogtocartbean);
			addcatalogtocartcall.callService();
			Logger.comment("addcatalogtocartcall send:" + addcatalogtocartcall.getEntityString());
			Logger.comment("addcatalogtocartcall return:" + addcatalogtocartcall.getReturnData());
			Logger.verifyEquals(ECode.SUCCESS, addcatalogtocartcall.getCode(), "验证返回code");
			Logger.verifyEquals(ECode.BCODE0, addcatalogtocartcall.getBCode(), "验证返回bcode");
			// 验证add数据加入到mongodb
			ShopCartMongoBean mongore = scmw.getOneShoppingCartInfo("{\"uid\" : \"" + uid + "\"}");
			Logger.verifyNotNull(mongore, "验证mongodb中有此用户的数据");
			Logger.verifyEquals(appid, mongore.getApp(), "验证appid");
			Logger.verifyEquals(catalogId, mongore.getCid(), "验证catalogId");
			Logger.verifyEquals(count, mongore.getNum(), "验证Num");
			Logger.verifyEquals("2", mongore.getCountry(), "验证CountryId");
			Logger.verifyEquals(sellerId, mongore.getSid(), "验证sellerId");
			Logger.verifyEquals(loginId, mongore.getSname(), "验证loginId");
			Logger.verifyNotNull(mongore.getCtime(), "验证有数据Ctime");
			Logger.verifyNotNull(mongore.getUtime(), "验证有数据Utime");
		} catch (Exception e) {
			Logger.fail(e);
		}

	}

	@Test
	@Category(P2.class)
	@TestCase
	public void Tc_AddCatalogToCart_002() {
		Logger.start(true,"商品不存在(CatalogId不存在),添加到购物车失败");
		try {
			// 随机获取appid 0~6 Unknown=0,洋码头PC端(1)
			// Ymt_PC=1,洋码头WAP(2)Ymt_WAP=2,洋码头APP(3)Ymt_APP=3,神器APP(4)Shangou_APP=4,神器WAP(5)Shangou_WAP=5,神器PC端(6)Shangou_PC=6
			Logger.comment("随机获取appid 0~6");
			String appid = String.valueOf(new Random().nextInt(7));
			Logger.comment("随机获取一个uuid");
			String uid = TestDataManager.getRandomUUID().toString();
			Map productinfo = ActivityInfo.getActiveProductInfoList().get(0);
			Logger.comment("从数据库中捞取一条记录，获取catalogId");
			String catalogId = (String) productinfo.get("CatalogId");
			Logger.comment("从数据库中捞取一条记录，获取SellerId");
			String sellerId = String.valueOf(productinfo.get("SellerId"));
			Logger.comment("从数据库中捞取一条记录，获取loginId");
			String loginId = String.valueOf(productinfo.get("loginId"));
			Logger.comment("setAppSource:" + appid);
			addcatalogtocartbean.setAppSource(appid);
			// Logger.comment("setCatalogId:"+catalogId);
			// addcatalogtocartbean.setCatalogId(catalogId);
			Logger.comment("setCount:" + "1");
			addcatalogtocartbean.setCount(1);
			Logger.comment("setCountryId:" + "2");
			addcatalogtocartbean.setCountryId("2");
			Logger.comment("setSellerId:" + sellerId);
			addcatalogtocartbean.setSellerId(sellerId);
			Logger.comment("setSellerLoginId:" + loginId);
			addcatalogtocartbean.setSellerLoginId(loginId);
			Logger.comment("setUserId:" + uid);
			addcatalogtocartbean.setUserId(uid);
			addcatalogtocartcall.setData(addcatalogtocartbean);
			addcatalogtocartcall.callService();
			Logger.comment("addcatalogtocartcall send:" + addcatalogtocartcall.getEntityString());
			Logger.comment("addcatalogtocartcall return:" + addcatalogtocartcall.getReturnData());
			Logger.verifyEquals(ECode.ERROR400, addcatalogtocartcall.getCode(), "验证返回code");
			Logger.verifyEquals(ECode.BCODE0, addcatalogtocartcall.getBCode(), "验证返回bcode");
			Logger.verifyEquals(true, addcatalogtocartcall.getMsg().contains(ECode.ERROR400_MSG_3), "验证返回Msg是否包含字符:"
					+ ECode.ERROR400_MSG_3);

		} catch (Exception e) {
			Logger.fail(e);
		}
	}

	@Test
	@Category(P2.class)
	@TestCase
	public void Tc_AddCatalogToCart_003() {
		Logger.start(true,"库存不足(Ymt_Products.isellnum=0?),添加到购物车失败");
		try {
			// 随机获取appid 0~6 Unknown=0,洋码头PC端(1)
			// Ymt_PC=1,洋码头WAP(2)Ymt_WAP=2,洋码头APP(3)Ymt_APP=3,神器APP(4)Shangou_APP=4,神器WAP(5)Shangou_WAP=5,神器PC端(6)Shangou_PC=6
			Logger.comment("随机获取appid 0~6");
			String appid = String.valueOf(new Random().nextInt(7));
			Logger.comment("随机获取一个uuid");
			String uid = TestDataManager.getRandomUUID().toString();
			Map productinfo = ActivityInfo.getActiveProductInfoList().get(0);
			Logger.comment("从数据库中捞取一条记录，获取catalogId");
			String catalogId = (String) productinfo.get("CatalogId");
			Logger.comment("从数据库中捞取一条记录，获取SellerId");
			String sellerId = String.valueOf(productinfo.get("SellerId"));
			Logger.comment("从数据库中捞取一条记录，获取loginId");
			String loginId = String.valueOf(productinfo.get("loginId"));
			Logger.comment("从数据库中捞取一条记录，获取inum");
			int inum = Integer.valueOf(productinfo.get("iNum").toString());
			Logger.comment("setAppSource:" + appid);
			addcatalogtocartbean.setAppSource(appid);
			Logger.comment("setCatalogId:" + catalogId);
			addcatalogtocartbean.setCatalogId(catalogId);
			// 设置count为inum+1 库存量+1
			Logger.comment("setCount:" + inum + 1);
			addcatalogtocartbean.setCount(inum + 1);
			Logger.comment("setCountryId:" + "2");
			addcatalogtocartbean.setCountryId("2");
			Logger.comment("setSellerId:" + sellerId);
			addcatalogtocartbean.setSellerId(sellerId);
			Logger.comment("setSellerLoginId:" + loginId);
			addcatalogtocartbean.setSellerLoginId(loginId);
			Logger.comment("setUserId:" + uid);
			addcatalogtocartbean.setUserId(uid);
			addcatalogtocartcall.setData(addcatalogtocartbean);
			addcatalogtocartcall.callService();
			Logger.comment("addcatalogtocartcall send:" + addcatalogtocartcall.getEntityString());
			Logger.comment("addcatalogtocartcall return:" + addcatalogtocartcall.getReturnData());
			Logger.verifyEquals(ECode.FAILED201, addcatalogtocartcall.getCode(), "验证返回code");
			Logger.verifyEquals(ECode.BCODE2, addcatalogtocartcall.getBCode(), "验证返回bcode");
			Logger.verifyEquals(true, addcatalogtocartcall.getMsg().contains(ECode.FAILED201_MSG_2), "验证返回Msg是否包含字符:"
					+ ECode.FAILED201_MSG_2);

		} catch (Exception e) {
			Logger.fail(e);
		}
	}

	@Test
	@Category(P2.class)
	@TestCase
	public void Tc_AddCatalogToCart_004() {
		Logger.start(true,"超过商品限购数量,添加到购物车失败");
		try {
			String uid = TestDataManager.getRandomUUID().toString();
			int isellerid = 1362789;
			Logger.comment("动态给用户添加一条购物车记录，uid：" + uid);
			// 创建产品
			Logger.comment("商家 " + isellerid + " 动态创建一个产品");
			Map productinfomap = ProductInfo.createProduct(isellerid, -1);
			Logger.comment("商品productid：" + productinfomap.get("sproductid"));
			Logger.comment("随机获取appid 0~6");
			String appid = String.valueOf(new Random().nextInt(7));
			Logger.comment("把刚刚添加的商品加入购物车");
			String catalogId = (String) productinfomap.get("scatalogid");
			String sellerId = String.valueOf(productinfomap.get("isellerid"));
			String loginId = String.valueOf(productinfomap.get("loginid"));
			// 设置count为限购数+1
			int count = (Integer) productinfomap.get("ilimitnum") + 1;
			Logger.comment("setAppSource:" + appid);
			addcatalogtocartbean.setAppSource(appid);
			Logger.comment("setCatalogId:" + catalogId);
			addcatalogtocartbean.setCatalogId(catalogId);
			Logger.comment("setCount:" + count);
			addcatalogtocartbean.setCount(count);
			Logger.comment("setCountryId:" + "2");
			addcatalogtocartbean.setCountryId("2");
			Logger.comment("setSellerId:" + sellerId);
			addcatalogtocartbean.setSellerId(sellerId);
			Logger.comment("setSellerLoginId:" + loginId);
			addcatalogtocartbean.setSellerLoginId(loginId);
			Logger.comment("setUserId:" + uid);
			addcatalogtocartbean.setUserId(uid);
			addcatalogtocartcall.setData(addcatalogtocartbean);
			addcatalogtocartcall.callService();
			Logger.comment("addcatalogtocartcall send:" + addcatalogtocartcall.getEntityString());
			Logger.comment("addcatalogtocartcall return:" + addcatalogtocartcall.getReturnData());
			Logger.verifyEquals(ECode.FAILED201, addcatalogtocartcall.getCode(), "验证返回code");
			Logger.verifyEquals(ECode.BCODE3, addcatalogtocartcall.getBCode(), "验证返回bcode");
			Logger.verifyEquals(true, addcatalogtocartcall.getMsg().contains(ECode.FAILED201_MSG_9), "验证返回Msg是否包含字符:"
					+ ECode.FAILED201_MSG_9);

		} catch (Exception e) {
			Logger.fail(e);
		}
	}

	@Test
	@Category(P2.class)
	@TestCase
	public void Tc_AddCatalogToCart_005() {
		Logger.start(true,"超过商品活动限购数量,添加到购物车失败");
		try {
			String uid = TestDataManager.getRandomUUID().toString();
			int isellerid = 1362789;
			Logger.comment("动态给用户添加一条购物车记录，uid：" + uid);
			// 创建产品
			Logger.comment("商家 " + isellerid + " 动态创建一个产品");
			Map productinfomap = ProductInfo.createProduct(isellerid, -1);
			Logger.debug(productinfomap);
			Logger.comment("商家 " + isellerid + " 动态给产品sproductid:" + (String) productinfomap.get("sproductid")
					+ "创建一个活动");
			ActivityInfo.createActivityBySproductid(isellerid, (String) productinfomap.get("sproductid"));
			Logger.comment(uid + ":把刚刚创建的产品加入到购物车中");
			Map activemap = ShoppingCartCallServices.addCatalogToCart(uid, productinfomap);
			Thread.sleep(2000);
			// Logger.debug(activemap);
			Logger.comment("商品productid：" + productinfomap.get("sproductid"));
			Logger.comment("随机获取appid 0~6");
			String appid = String.valueOf(new Random().nextInt(7));
			Logger.comment("把刚刚添加的商品加入购物车");
			String catalogId = (String) productinfomap.get("scatalogid");
			String sellerId = String.valueOf(productinfomap.get("isellerid"));
			String loginId = String.valueOf(productinfomap.get("loginid"));
			// 活动限购为1 写死 YmtActivityWapper#insertOneActivity setIlimitnum
			int count = 2;
			Logger.comment("setAppSource:" + appid);
			addcatalogtocartbean.setAppSource(appid);
			Logger.comment("setCatalogId:" + catalogId);
			addcatalogtocartbean.setCatalogId(catalogId);
			Logger.comment("setCount:" + count);
			addcatalogtocartbean.setCount(count);
			Logger.comment("setCountryId:" + "2");
			addcatalogtocartbean.setCountryId("2");
			Logger.comment("setSellerId:" + sellerId);
			addcatalogtocartbean.setSellerId(sellerId);
			Logger.comment("setSellerLoginId:" + loginId);
			addcatalogtocartbean.setSellerLoginId(loginId);
			Logger.comment("setUserId:" + uid);
			addcatalogtocartbean.setUserId(uid);
			addcatalogtocartcall.setData(addcatalogtocartbean);
			addcatalogtocartcall.callService();
			Logger.comment("addcatalogtocartcall send:" + addcatalogtocartcall.getEntityString());
			Logger.comment("addcatalogtocartcall return:" + addcatalogtocartcall.getReturnData());
			Logger.verifyEquals(ECode.FAILED201, addcatalogtocartcall.getCode(), "验证返回code");
			Logger.verifyEquals(ECode.BCODE4, addcatalogtocartcall.getBCode(), "验证返回bcode");
			Logger.verifyEquals(true, addcatalogtocartcall.getMsg().contains(ECode.FAILED201_MSG_8), "验证返回Msg是否包含字符:"
					+ ECode.FAILED201_MSG_8);

		} catch (Exception e) {
			Logger.fail(e);
		}
	}

	@Test
	@Category(P2.class)
	@TestCase
	public void Tc_AddCatalogToCart_006() {
		Logger.start(true,"未找到指定购物车项,添加到购物车失败");
		try {
			// 随机获取appid 0~6 Unknown=0,洋码头PC端(1)
			// Ymt_PC=1,洋码头WAP(2)Ymt_WAP=2,洋码头APP(3)Ymt_APP=3,神器APP(4)Shangou_APP=4,神器WAP(5)Shangou_WAP=5,神器PC端(6)Shangou_PC=6
			Logger.comment("随机获取appid 0~6");
			String appid = String.valueOf(new Random().nextInt(7));
			Logger.comment("随机获取一个uuid");
			String uid = TestDataManager.getRandomUUID().toString();
			Map productinfo = ActivityInfo.getActiveProductInfoList().get(0);
			// Logger.comment("从数据库中捞取一条记录，获取catalogId");
			// String catalogId=(String) productinfo.get("CatalogId");
			Logger.comment("从数据库中捞取一条记录，获取SellerId");
			String sellerId = String.valueOf(productinfo.get("SellerId"));
			Logger.comment("从数据库中捞取一条记录，获取loginId");
			String loginId = String.valueOf(productinfo.get("loginId"));
			Logger.comment("从数据库中捞取一条记录，获取inum");
			int inum = Integer.valueOf(productinfo.get("iNum").toString());
			Logger.comment("setAppSource:" + appid);
			addcatalogtocartbean.setAppSource(appid);
			Logger.comment("setCatalogId:" + "12345");
			addcatalogtocartbean.setCatalogId("12345");
			Logger.comment("setCount:" + inum + 1);
			addcatalogtocartbean.setCount(inum + 1);
			Logger.comment("setCountryId:" + "2");
			addcatalogtocartbean.setCountryId("2");
			Logger.comment("setSellerId:" + sellerId);
			addcatalogtocartbean.setSellerId(sellerId);
			Logger.comment("setSellerLoginId:" + loginId);
			addcatalogtocartbean.setSellerLoginId(loginId);
			Logger.comment("setUserId:" + uid);
			addcatalogtocartbean.setUserId(uid);
			addcatalogtocartcall.setData(addcatalogtocartbean);
			addcatalogtocartcall.callService();
			Logger.comment("addcatalogtocartcall send:" + addcatalogtocartcall.getEntityString());
			Logger.comment("addcatalogtocartcall return:" + addcatalogtocartcall.getReturnData());
			Logger.verifyEquals(ECode.FAILED201, addcatalogtocartcall.getCode(), "验证返回code");
			Logger.verifyEquals(ECode.BCODE1, addcatalogtocartcall.getBCode(), "验证返回bcode");
			Logger.verifyEquals(true, addcatalogtocartcall.getMsg().contains(ECode.FAILED201_MSG_3), "验证返回Msg是否包含字符:"
					+ ECode.FAILED201_MSG_3);

		} catch (Exception e) {
			Logger.fail(e);
		}
	}

	@Test
	@Category(P3.class)
	@TestCase
	public void Tc_AddCatalogToCart_007() {
		Logger.start(true,"未输入必填项UserId,添加到购物车失败");
		try {
			// 随机获取appid 0~6 Unknown=0,洋码头PC端(1)
			// Ymt_PC=1,洋码头WAP(2)Ymt_WAP=2,洋码头APP(3)Ymt_APP=3,神器APP(4)Shangou_APP=4,神器WAP(5)Shangou_WAP=5,神器PC端(6)Shangou_PC=6
			Logger.comment("随机获取appid 0~6");
			String appid = String.valueOf(new Random().nextInt(7));
			Logger.comment("随机获取一个uuid");
			String uid = TestDataManager.getRandomUUID().toString();
			Map productinfo = ActivityInfo.getActiveProductInfoList().get(0);
			Logger.comment("从数据库中捞取一条记录，获取catalogId");
			String catalogId = (String) productinfo.get("CatalogId");
			Logger.comment("从数据库中捞取一条记录，获取SellerId");
			String sellerId = String.valueOf(productinfo.get("SellerId"));
			Logger.comment("从数据库中捞取一条记录，获取loginId");
			String loginId = String.valueOf(productinfo.get("loginId"));
			Logger.comment("setAppSource:" + appid);
			addcatalogtocartbean.setAppSource(appid);
			Logger.comment("setCatalogId:" + catalogId);
			addcatalogtocartbean.setCatalogId(catalogId);
			Logger.comment("setCount:" + "1");
			addcatalogtocartbean.setCount(1);
			Logger.comment("setCountryId:" + "2");
			addcatalogtocartbean.setCountryId("2");
			Logger.comment("setSellerId:" + sellerId);
			addcatalogtocartbean.setSellerId(sellerId);
			Logger.comment("setSellerLoginId:" + loginId);
			addcatalogtocartbean.setSellerLoginId(loginId);
			// Logger.comment("setUserId:"+uid);
			// addcatalogtocartbean.setUserId(uid);
			addcatalogtocartcall.setData(addcatalogtocartbean);
			addcatalogtocartcall.callService();
			Logger.comment("addcatalogtocartcall send:" + addcatalogtocartcall.getEntityString());
			Logger.comment("addcatalogtocartcall return:" + addcatalogtocartcall.getReturnData());
			Logger.verifyEquals(ECode.ERROR400, addcatalogtocartcall.getCode(), "验证返回code");
			Logger.verifyEquals(ECode.BCODE0, addcatalogtocartcall.getBCode(), "验证返回bcode");
			Logger.verifyEquals(true, addcatalogtocartcall.getMsg().contains(ECode.ERROR400_MSG_1), "验证返回Msg是否包含字符:"
					+ ECode.ERROR400_MSG_1);

		} catch (Exception e) {
			Logger.fail(e);
		}
	}

	@Test
	@Category(P3.class)
	@TestCase
	public void Tc_AddCatalogToCart_008() {
		Logger.start(true,"未输入必填项CatalogId,添加到购物车失败");
		try {
			// 随机获取appid 0~6 Unknown=0,洋码头PC端(1)
			// Ymt_PC=1,洋码头WAP(2)Ymt_WAP=2,洋码头APP(3)Ymt_APP=3,神器APP(4)Shangou_APP=4,神器WAP(5)Shangou_WAP=5,神器PC端(6)Shangou_PC=6
			Logger.comment("随机获取appid 0~6");
			String appid = String.valueOf(new Random().nextInt(7));
			Logger.comment("随机获取一个uuid");
			String uid = TestDataManager.getRandomUUID().toString();
			Map productinfo = ActivityInfo.getActiveProductInfoList().get(0);
			Logger.comment("从数据库中捞取一条记录，获取catalogId");
			String catalogId = (String) productinfo.get("CatalogId");
			Logger.comment("从数据库中捞取一条记录，获取SellerId");
			String sellerId = String.valueOf(productinfo.get("SellerId"));
			Logger.comment("从数据库中捞取一条记录，获取loginId");
			String loginId = String.valueOf(productinfo.get("loginId"));
			Logger.comment("setAppSource:" + appid);
			addcatalogtocartbean.setAppSource(appid);
			// Logger.comment("setCatalogId:"+catalogId);
			// addcatalogtocartbean.setCatalogId(catalogId);
			Logger.comment("setCount:" + "1");
			addcatalogtocartbean.setCount(1);
			Logger.comment("setCountryId:" + "2");
			addcatalogtocartbean.setCountryId("2");
			Logger.comment("setSellerId:" + sellerId);
			addcatalogtocartbean.setSellerId(sellerId);
			Logger.comment("setSellerLoginId:" + loginId);
			addcatalogtocartbean.setSellerLoginId(loginId);
			Logger.comment("setUserId:" + uid);
			addcatalogtocartbean.setUserId(uid);
			addcatalogtocartcall.setData(addcatalogtocartbean);
			addcatalogtocartcall.callService();
			Logger.comment("addcatalogtocartcall send:" + addcatalogtocartcall.getEntityString());
			Logger.comment("addcatalogtocartcall return:" + addcatalogtocartcall.getReturnData());
			Logger.verifyEquals(ECode.ERROR400, addcatalogtocartcall.getCode(), "验证返回code");
			Logger.verifyEquals(ECode.BCODE0, addcatalogtocartcall.getBCode(), "验证返回bcode");
			Logger.verifyEquals(true, addcatalogtocartcall.getMsg().contains(ECode.ERROR400_MSG_3), "验证返回Msg是否包含字符:"
					+ ECode.ERROR400_MSG_3);

		} catch (Exception e) {
			Logger.fail(e);
		}
	}

	@Test
	@Category(P3.class)
	@TestCase
	public void Tc_AddCatalogToCart_009() {
		Logger.start(true,"未输入必填项Count,添加到购物车失败");
		try {
			// 随机获取appid 0~6 Unknown=0,洋码头PC端(1)
			// Ymt_PC=1,洋码头WAP(2)Ymt_WAP=2,洋码头APP(3)Ymt_APP=3,神器APP(4)Shangou_APP=4,神器WAP(5)Shangou_WAP=5,神器PC端(6)Shangou_PC=6
			Logger.comment("随机获取appid 0~6");
			String appid = String.valueOf(new Random().nextInt(7));
			Logger.comment("随机获取一个uuid");
			String uid = TestDataManager.getRandomUUID().toString();
			Map productinfo = ActivityInfo.getActiveProductInfoList().get(0);
			Logger.comment("从数据库中捞取一条记录，获取catalogId");
			String catalogId = (String) productinfo.get("CatalogId");
			Logger.comment("从数据库中捞取一条记录，获取SellerId");
			String sellerId = String.valueOf(productinfo.get("SellerId"));
			Logger.comment("从数据库中捞取一条记录，获取loginId");
			String loginId = String.valueOf(productinfo.get("loginId"));
			Logger.comment("setAppSource:" + appid);
			addcatalogtocartbean.setAppSource(appid);
			Logger.comment("setCatalogId:" + catalogId);
			addcatalogtocartbean.setCatalogId(catalogId);
			// Logger.comment("setCount:"+"1");
			// addcatalogtocartbean.setCount("1");
			Logger.comment("setCountryId:" + "2");
			addcatalogtocartbean.setCountryId("2");
			Logger.comment("setSellerId:" + sellerId);
			addcatalogtocartbean.setSellerId(sellerId);
			Logger.comment("setSellerLoginId:" + loginId);
			addcatalogtocartbean.setSellerLoginId(loginId);
			Logger.comment("setUserId:" + uid);
			addcatalogtocartbean.setUserId(uid);
			addcatalogtocartcall.setData(addcatalogtocartbean);
			addcatalogtocartcall.callService();
			Logger.comment("addcatalogtocartcall send:" + addcatalogtocartcall.getEntityString());
			Logger.comment("addcatalogtocartcall return:" + addcatalogtocartcall.getReturnData());
			Logger.verifyEquals(ECode.ERROR400, addcatalogtocartcall.getCode(), "验证返回code");
			Logger.verifyEquals(ECode.BCODE0, addcatalogtocartcall.getBCode(), "验证返回bcode");
			Logger.verifyEquals(true, addcatalogtocartcall.getMsg().contains(ECode.ERROR400_MSG_4), "验证返回Msg是否包含字符:"
					+ ECode.ERROR400_MSG_4);

		} catch (Exception e) {
			Logger.fail(e);
		}
	}

	@Test
	@Category(P3.class)
	@TestCase
	public void Tc_AddCatalogToCart_010() {
		Logger.start(true,"输入Count小于0,添加到购物车失败");
		try {
			// 随机获取appid 0~6 Unknown=0,洋码头PC端(1)
			// Ymt_PC=1,洋码头WAP(2)Ymt_WAP=2,洋码头APP(3)Ymt_APP=3,神器APP(4)Shangou_APP=4,神器WAP(5)Shangou_WAP=5,神器PC端(6)Shangou_PC=6
			Logger.comment("随机获取appid 0~6");
			String appid = String.valueOf(new Random().nextInt(7));
			Logger.comment("随机获取一个uuid");
			String uid = TestDataManager.getRandomUUID().toString();
			Map productinfo = ActivityInfo.getActiveProductInfoList().get(0);
			Logger.comment("从数据库中捞取一条记录，获取catalogId");
			String catalogId = (String) productinfo.get("CatalogId");
			Logger.comment("从数据库中捞取一条记录，获取SellerId");
			String sellerId = String.valueOf(productinfo.get("SellerId"));
			Logger.comment("从数据库中捞取一条记录，获取loginId");
			String loginId = String.valueOf(productinfo.get("loginId"));
			Logger.comment("setAppSource:" + appid);
			addcatalogtocartbean.setAppSource(appid);
			Logger.comment("setCatalogId:" + catalogId);
			addcatalogtocartbean.setCatalogId(catalogId);
			Logger.comment("setCount:" + "-1");
			addcatalogtocartbean.setCount(-1);
			Logger.comment("setCountryId:" + "2");
			addcatalogtocartbean.setCountryId("2");
			Logger.comment("setSellerId:" + sellerId);
			addcatalogtocartbean.setSellerId(sellerId);
			Logger.comment("setSellerLoginId:" + loginId);
			addcatalogtocartbean.setSellerLoginId(loginId);
			Logger.comment("setUserId:" + uid);
			addcatalogtocartbean.setUserId(uid);
			addcatalogtocartcall.setData(addcatalogtocartbean);
			addcatalogtocartcall.callService();
			Logger.comment("addcatalogtocartcall send:" + addcatalogtocartcall.getEntityString());
			Logger.comment("addcatalogtocartcall return:" + addcatalogtocartcall.getReturnData());
			Logger.verifyEquals(ECode.ERROR400, addcatalogtocartcall.getCode(), "验证返回code");
			Logger.verifyEquals(ECode.BCODE0, addcatalogtocartcall.getBCode(), "验证返回bcode");
			Logger.verifyEquals(true, addcatalogtocartcall.getMsg().contains(ECode.ERROR400_MSG_4), "验证返回Msg是否包含字符:"
					+ ECode.ERROR400_MSG_4);

		} catch (Exception e) {
			Logger.fail(e);
		}
	}

	@Test
	@Category(P3.class)
	@TestCase
	public void Tc_AddCatalogToCart_011() {
		// SellerLoginId需要外部系统保证正确传入，购物车接口本身不做判断
		Logger.start(true,"未输入SellerLoginId,添加到购物车成功");
		try {
			// 随机获取appid 0~6 Unknown=0,洋码头PC端(1)
			// Ymt_PC=1,洋码头WAP(2)Ymt_WAP=2,洋码头APP(3)Ymt_APP=3,神器APP(4)Shangou_APP=4,神器WAP(5)Shangou_WAP=5,神器PC端(6)Shangou_PC=6
			Logger.comment("随机获取appid 0~6");
			String appid = String.valueOf(new Random().nextInt(7));
			Logger.comment("随机获取一个uuid");
			String uid = TestDataManager.getRandomUUID().toString();
			Map productinfo = ActivityInfo.getActiveProductInfoList().get(0);
			Logger.comment("从数据库中捞取一条记录，获取catalogId");
			String catalogId = (String) productinfo.get("CatalogId");
			Logger.comment("从数据库中捞取一条记录，获取SellerId");
			String sellerId = String.valueOf(productinfo.get("SellerId"));
			Logger.comment("从数据库中捞取一条记录，获取loginId");
			String loginId = String.valueOf(productinfo.get("loginId"));
			Logger.comment("setAppSource:" + appid);
			addcatalogtocartbean.setAppSource(appid);
			Logger.comment("setCatalogId:" + catalogId);
			addcatalogtocartbean.setCatalogId(catalogId);
			Logger.comment("setCount:" + "1");
			addcatalogtocartbean.setCount(1);
			Logger.comment("setCountryId:" + "2");
			addcatalogtocartbean.setCountryId("2");
			Logger.comment("setSellerId:" + sellerId);
			addcatalogtocartbean.setSellerId(sellerId);
			// Logger.comment("setSellerLoginId:"+loginId);
			// addcatalogtocartbean.setSellerLoginId(loginId);
			Logger.comment("setUserId:" + uid);
			addcatalogtocartbean.setUserId(uid);
			addcatalogtocartcall.setData(addcatalogtocartbean);
			addcatalogtocartcall.callService();
			Logger.comment("addcatalogtocartcall send:" + addcatalogtocartcall.getEntityString());
			Logger.comment("addcatalogtocartcall return:" + addcatalogtocartcall.getReturnData());
			Logger.verifyEquals(ECode.SUCCESS, addcatalogtocartcall.getCode(), "验证返回code");
			Logger.verifyEquals(ECode.BCODE0, addcatalogtocartcall.getBCode(), "验证返回bcode");
		} catch (Exception e) {
			Logger.fail(e);
		}
	}

	@Test
	@Category(P3.class)
	@TestCase
	public void Tc_AddCatalogToCart_012() {
		// SellerId需要外部系统保证正确传入，购物车接口本身不做判断
		Logger.start(true,"未输入SellerId,添加到购物车成功");
		try {
			// 随机获取appid 0~6 Unknown=0,洋码头PC端(1)
			// Ymt_PC=1,洋码头WAP(2)Ymt_WAP=2,洋码头APP(3)Ymt_APP=3,神器APP(4)Shangou_APP=4,神器WAP(5)Shangou_WAP=5,神器PC端(6)Shangou_PC=6
			Logger.comment("随机获取appid 0~6");
			String appid = String.valueOf(new Random().nextInt(7));
			Logger.comment("随机获取一个uuid");
			String uid = TestDataManager.getRandomUUID().toString();
			Map productinfo = ActivityInfo.getActiveProductInfoList().get(0);
			Logger.comment("从数据库中捞取一条记录，获取catalogId");
			String catalogId = (String) productinfo.get("CatalogId");
			Logger.comment("从数据库中捞取一条记录，获取SellerId");
			String sellerId = String.valueOf(productinfo.get("SellerId"));
			Logger.comment("从数据库中捞取一条记录，获取loginId");
			String loginId = String.valueOf(productinfo.get("loginId"));
			Logger.comment("setAppSource:" + appid);
			addcatalogtocartbean.setAppSource(appid);
			Logger.comment("setCatalogId:" + catalogId);
			addcatalogtocartbean.setCatalogId(catalogId);
			Logger.comment("setCount:" + "1");
			addcatalogtocartbean.setCount(1);
			Logger.comment("setCountryId:" + "2");
			addcatalogtocartbean.setCountryId("2");
			// Logger.comment("setSellerId:"+sellerId);
			// addcatalogtocartbean.setSellerId(sellerId);
			Logger.comment("setSellerLoginId:" + loginId);
			addcatalogtocartbean.setSellerLoginId(loginId);
			Logger.comment("setUserId:" + uid);
			addcatalogtocartbean.setUserId(uid);
			addcatalogtocartcall.setData(addcatalogtocartbean);
			addcatalogtocartcall.callService();
			Logger.comment("addcatalogtocartcall send:" + addcatalogtocartcall.getEntityString());
			Logger.comment("addcatalogtocartcall return:" + addcatalogtocartcall.getReturnData());
			Logger.verifyEquals(ECode.SUCCESS, addcatalogtocartcall.getCode(), "验证返回code");
			Logger.verifyEquals(ECode.BCODE0, addcatalogtocartcall.getBCode(), "验证返回bcode");

		} catch (Exception e) {
			Logger.fail(e);
		}
	}

	@Test
	@Category(P3.class)
	@TestCase
	public void Tc_AddCatalogToCart_013() {
		Logger.start(true,"未输入非必填项AppSource,添加到购物车成功");
		try {
			// 随机获取appid 0~6 Unknown=0,洋码头PC端(1)
			// Ymt_PC=1,洋码头WAP(2)Ymt_WAP=2,洋码头APP(3)Ymt_APP=3,神器APP(4)Shangou_APP=4,神器WAP(5)Shangou_WAP=5,神器PC端(6)Shangou_PC=6
			// Logger.comment("随机获取appid 0~6");
			// String appid=String.valueOf(new Random().nextInt(7));
			Logger.comment("随机获取一个uuid");
			String uid = TestDataManager.getRandomUUID().toString();
			Map productinfo = ActivityInfo.getActiveProductInfoList().get(0);
			Logger.comment("从数据库中捞取一条记录，获取catalogId");
			String catalogId = (String) productinfo.get("CatalogId");
			Logger.comment("从数据库中捞取一条记录，获取SellerId");
			String sellerId = String.valueOf(productinfo.get("SellerId"));
			Logger.comment("从数据库中捞取一条记录，获取loginId");
			String loginId = String.valueOf(productinfo.get("loginId"));
			int count = 1;
			// Logger.comment("setAppSource:"+appid);
			// addcatalogtocartbean.setAppSource(appid);
			Logger.comment("setCatalogId:" + catalogId);
			addcatalogtocartbean.setCatalogId(catalogId);
			Logger.comment("setCount:" + count);
			addcatalogtocartbean.setCount(count);
			Logger.comment("setCountryId:" + "2");
			addcatalogtocartbean.setCountryId("2");
			Logger.comment("setSellerId:" + sellerId);
			addcatalogtocartbean.setSellerId(sellerId);
			Logger.comment("setSellerLoginId:" + loginId);
			addcatalogtocartbean.setSellerLoginId(loginId);
			Logger.comment("setUserId:" + uid);
			addcatalogtocartbean.setUserId(uid);
			addcatalogtocartcall.setData(addcatalogtocartbean);
			addcatalogtocartcall.callService();
			Logger.comment("addcatalogtocartcall send:" + addcatalogtocartcall.getEntityString());
			Logger.comment("addcatalogtocartcall return:" + addcatalogtocartcall.getReturnData());
			Logger.verifyEquals(ECode.SUCCESS, addcatalogtocartcall.getCode(), "验证返回code");
			Logger.verifyEquals(ECode.BCODE0, addcatalogtocartcall.getBCode(), "验证返回bcode");
			ShopCartMongoBean mongore = scmw.getOneShoppingCartInfo("{\"uid\" : \"" + uid + "\"}");
			Logger.verifyNotNull(mongore, "验证mongodb中有此用户的数据");
			Logger.verifyEquals("0", mongore.getApp(), "验证appid");
			Logger.verifyEquals(catalogId, mongore.getCid(), "验证catalogId");
			Logger.verifyEquals(count, mongore.getNum(), "验证Num");
			Logger.verifyEquals("2", mongore.getCountry(), "验证CountryId");
			Logger.verifyEquals(sellerId, mongore.getSid(), "验证sellerId");
			Logger.verifyEquals(loginId, mongore.getSname(), "验证loginId");
			Logger.verifyNotNull(mongore.getCtime(), "验证有数据Ctime");
			Logger.verifyNotNull(mongore.getUtime(), "验证有数据Utime");

		} catch (Exception e) {
			Logger.fail(e);
		}
	}

	@Test
	@Category(P3.class)
	@TestCase
	public void Tc_AddCatalogToCart_014() {
		// CountryId需要外部系统保证正确传入，购物车接口本身不做判断
		Logger.start(true,"未输入CountryId,添加到购物车成功");
		try {
			// 随机获取appid 0~6 Unknown=0,洋码头PC端(1)
			// Ymt_PC=1,洋码头WAP(2)Ymt_WAP=2,洋码头APP(3)Ymt_APP=3,神器APP(4)Shangou_APP=4,神器WAP(5)Shangou_WAP=5,神器PC端(6)Shangou_PC=6
			Logger.comment("随机获取appid 0~6");
			String appid = String.valueOf(new Random().nextInt(7));
			Logger.comment("随机获取一个uuid");
			String uid = TestDataManager.getRandomUUID().toString();
			Map productinfo = ActivityInfo.getActiveProductInfoList().get(0);
			Logger.comment("从数据库中捞取一条记录，获取catalogId");
			String catalogId = (String) productinfo.get("CatalogId");
			Logger.comment("从数据库中捞取一条记录，获取SellerId");
			String sellerId = String.valueOf(productinfo.get("SellerId"));
			Logger.comment("从数据库中捞取一条记录，获取loginId");
			String loginId = String.valueOf(productinfo.get("loginId"));
			int count = 1;
			Logger.comment("setAppSource:" + appid);
			addcatalogtocartbean.setAppSource(appid);
			Logger.comment("setCatalogId:" + catalogId);
			addcatalogtocartbean.setCatalogId(catalogId);
			Logger.comment("setCount:" + count);
			addcatalogtocartbean.setCount(count);
			// Logger.comment("setCountryId:"+"2");
			// addcatalogtocartbean.setCountryId("2");
			Logger.comment("setSellerId:" + sellerId);
			addcatalogtocartbean.setSellerId(sellerId);
			Logger.comment("setSellerLoginId:" + loginId);
			addcatalogtocartbean.setSellerLoginId(loginId);
			Logger.comment("setUserId:" + uid);
			addcatalogtocartbean.setUserId(uid);
			addcatalogtocartcall.setData(addcatalogtocartbean);
			addcatalogtocartcall.callService();
			Logger.comment("addcatalogtocartcall send:" + addcatalogtocartcall.getEntityString());
			Logger.comment("addcatalogtocartcall return:" + addcatalogtocartcall.getReturnData());
			Logger.verifyEquals(ECode.SUCCESS, addcatalogtocartcall.getCode(), "验证返回code");
			Logger.verifyEquals(ECode.BCODE0, addcatalogtocartcall.getBCode(), "验证返回bcode");

		} catch (Exception e) {
			Logger.fail(e);
		}
	}

	@Test
	@Category(P3.class)
	@TestCase
	public void Tc_AddCatalogToCart_015() {
		Logger.start(true,"输入CountryId小于0,添加到购物车失败");
		try {
			// 随机获取appid 0~6 Unknown=0,洋码头PC端(1)
			// Ymt_PC=1,洋码头WAP(2)Ymt_WAP=2,洋码头APP(3)Ymt_APP=3,神器APP(4)Shangou_APP=4,神器WAP(5)Shangou_WAP=5,神器PC端(6)Shangou_PC=6
			Logger.comment("随机获取appid 0~6");
			String appid = String.valueOf(new Random().nextInt(7));
			Logger.comment("随机获取一个uuid");
			String uid = TestDataManager.getRandomUUID().toString();
			Map productinfo = ActivityInfo.getActiveProductInfoList().get(0);
			Logger.comment("从数据库中捞取一条记录，获取catalogId");
			String catalogId = (String) productinfo.get("CatalogId");
			Logger.comment("从数据库中捞取一条记录，获取SellerId");
			String sellerId = String.valueOf(productinfo.get("SellerId"));
			Logger.comment("从数据库中捞取一条记录，获取loginId");
			String loginId = String.valueOf(productinfo.get("loginId"));
			Logger.comment("setAppSource:" + appid);
			addcatalogtocartbean.setAppSource(appid);
			Logger.comment("setCatalogId:" + catalogId);
			addcatalogtocartbean.setCatalogId(catalogId);
			Logger.comment("setCount:" + "1");
			addcatalogtocartbean.setCount(1);
			Logger.comment("setCountryId:" + "-1");
			addcatalogtocartbean.setCountryId("-1");
			Logger.comment("setSellerId:" + sellerId);
			addcatalogtocartbean.setSellerId(sellerId);
			Logger.comment("setSellerLoginId:" + loginId);
			addcatalogtocartbean.setSellerLoginId(loginId);
			Logger.comment("setUserId:" + uid);
			addcatalogtocartbean.setUserId(uid);
			addcatalogtocartcall.setData(addcatalogtocartbean);
			addcatalogtocartcall.callService();
			Logger.comment("addcatalogtocartcall send:" + addcatalogtocartcall.getEntityString());
			Logger.comment("addcatalogtocartcall return:" + addcatalogtocartcall.getReturnData());
			Logger.verifyEquals(ECode.ERROR400, addcatalogtocartcall.getCode(), "验证返回code");
			Logger.verifyEquals(ECode.BCODE0, addcatalogtocartcall.getBCode(), "验证返回bcode");
			Logger.verifyEquals(true, addcatalogtocartcall.getMsg().contains(ECode.ERROR400_MSG_5), "验证返回Msg是否包含字符:"
					+ ECode.ERROR400_MSG_5);

		} catch (Exception e) {
			Logger.fail(e);
		}
	}*/

}